<?php
class Database
{	
	
	public function __construct() {
		
	}
	
	/*
	 * Connect to a database;
	 */
	public function databaseConnect() {
		global $config;
		
		$GLOBALS["database_link"] = mysql_connect("localhost","root","");
		
		mysql_select_db("unwdmi");
	}

	/*
	 * Disconnect from the database
	 */
	public function databaseDisconnect() {
			mysql_close($GLOBALS["database_link"]);
	}
	
	/*
	 * Select data from the database
	 * $query = Query to execute
	 */
	public function select($query) {
		mysql_select_db("unwdmi", $GLOBALS["database_link"]);
		$result = mysql_query($query);
		$data = array(array());
		//Counter variable
		$i = 0;
		while($row = mysql_fetch_array($result))
		{	
			for($j=0;$j<mysql_num_fields($result);$j++) {
				//Add row to array
				$data[$i][$j] = $row[$j];
			}
			$i++;
		}
		return $data;
	}
	
}